<?php
class ProjectStatusesController extends AppController
{
    public $name = 'ProjectStatuses';
    public function admin_index()
    {
        $this->pageTitle = __l('Project Statuses');
        $this->ProjectStatus->recursive = 1;
        $this->paginate = array(
            'contain' => array(
                'Project' => array(
                    'fields' => array(
                        'Project.id',
                    ) ,
                ) ,
            ) ,
            'order' => array(
                'ProjectStatus.id' => 'desc'
            )
        );
        $this->set('projectStatuses', $this->paginate());
    }
    public function admin_edit($id = null)
    {
        $this->pageTitle = __l('Edit Project Status');
        if (is_null($id)) {
            throw new NotFoundException(__l('Invalid request'));
        }
        if (!empty($this->request->data)) {
            if ($this->ProjectStatus->save($this->request->data)) {
                $this->Session->setFlash(__l('Project Status has been updated') , 'default', null, 'success');
            } else {
                $this->Session->setFlash(__l('Project Status could not be updated. Please, try again.') , 'default', null, 'error');
            }
        } else {
            $this->request->data = $this->ProjectStatus->read(null, $id);
            if (empty($this->request->data)) {
                throw new NotFoundException(__l('Invalid request'));
            }
        }
        $this->pageTitle.= ' - ' . $this->request->data['ProjectStatus']['name'];
    }
}
?>